<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="parent" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{parentHome.managed ? 'Edit' : 'Add'} Parent</f:facet>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                       required="true"
                       disabled="#{parentHome.managed}"
                          value="#{parentHome.instance.id}">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>






            <s:decorate id="firstNameField" template="layout/edit.xhtml">
                <ui:define name="label">First name</ui:define>
                <h:inputText id="firstName"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{parentHome.instance.firstName}">
                    <a:support event="onblur" reRender="firstNameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="lastNameField" template="layout/edit.xhtml">
                <ui:define name="label">Last name</ui:define>
                <h:inputText id="lastName"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{parentHome.instance.lastName}">
                    <a:support event="onblur" reRender="lastNameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="mobileNumberField" template="layout/edit.xhtml">
                <ui:define name="label">Mobile number</ui:define>
                <h:inputText id="mobileNumber"
                       required="true"
                          value="#{parentHome.instance.mobileNumber}">
                    <a:support event="onblur" reRender="mobileNumberField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="officePhoneField" template="layout/edit.xhtml">
                <ui:define name="label">Office phone</ui:define>
                <h:inputText id="officePhone"
                       required="true"
                          value="#{parentHome.instance.officePhone}">
                    <a:support event="onblur" reRender="officePhoneField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="emailField" template="layout/edit.xhtml">
                <ui:define name="label">Email</ui:define>
                <h:inputText id="email"
                           size="100"
                      maxlength="150"
                          value="#{parentHome.instance.email}">
                    <a:support event="onblur" reRender="emailField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{parentHome.persist}"
                       disabled="#{!parentHome.wired}"
                       rendered="#{!parentHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{parentHome.update}"
                       rendered="#{parentHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{parentHome.remove}"
                      immediate="true"
                       rendered="#{parentHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Parent.xhtml"
                rendered="#{parentHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty parentFrom ? 'ParentList' : parentFrom}.xhtml"
                rendered="#{!parentHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="UserAccount">
    <div class="association" id="userAccountParent">

        <h:outputText value="There is no userAccount associated with this parent."
                   rendered="#{parentHome.instance.userAccount == null}"/>

        <rich:dataTable var="_userAccount"
                   value="#{parentHome.instance.userAccount}"
                rendered="#{parentHome.instance.userAccount != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="userAccountTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_userAccount.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">UserAccountname</f:facet>
                <h:outputText value="#{_userAccount.username}"/>
            </h:column>
          
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{parentHome.instance.userAccount != null ? 'changeParentuserAccount' : 'selectParentuserAccount'}" value="#{parentHome.instance.userAccount != null ? 'Change' : 'Select'} userAccount"
                       view="/UserAccountList.xhtml">
                       
                       
                <f:param name="from" value="ParentEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Student *" labelClass="required">
    <div class="association" id="studentParent">

        <h:outputText value="There is no student associated with this parent."
                   rendered="#{parentHome.instance.student == null}"/>

        <rich:dataTable var="_student"
                   value="#{parentHome.instance.student}"
                rendered="#{parentHome.instance.student != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="studentTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_student.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">UserAccount id</f:facet>
                <h:outputText value="#{_student.userAccount.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Course id</f:facet>
                <h:outputText value="#{_student.course.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">First name</f:facet>
                <h:outputText value="#{_student.firstName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Last name</f:facet>
                <h:outputText value="#{_student.lastName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Passport photo url</f:facet>
                <h:outputText value="#{_student.passportPhotoUrl}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Date of birth</f:facet>
                <h:outputText value="#{_student.dateOfBirth}">
                    <s:convertDateTime type="date" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Register number</f:facet>
                <h:outputText value="#{_student.registerNumber}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Roll number</f:facet>
                <h:outputText value="#{_student.rollNumber}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{parentHome.instance.student != null ? 'changeParentstudent' : 'selectParentstudent'}" value="#{parentHome.instance.student != null ? 'Change' : 'Select'} student"
                       view="/StudentList.xhtml">
                       
                       
                <f:param name="from" value="ParentEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Relationship">
    <div class="association" id="relationshipParent">

        <h:outputText value="There is no relationship associated with this parent."
                   rendered="#{parentHome.instance.relationship == null}"/>

        <rich:dataTable var="_relationship"
                   value="#{parentHome.instance.relationship}"
                rendered="#{parentHome.instance.relationship != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="relationshipTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_relationship.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Relation name</f:facet>
                <h:outputText value="#{_relationship.relationName}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Relation desc</f:facet>
                <h:outputText value="#{_relationship.relationDesc}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{parentHome.instance.relationship != null ? 'changeParentrelationship' : 'selectParentrelationship'}" value="#{parentHome.instance.relationship != null ? 'Change' : 'Select'} relationship"
                       view="/RelationshipList.xhtml">
                       
                       
                <f:param name="from" value="ParentEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Address *" labelClass="required">
    <div class="association" id="addressParent">

        <h:outputText value="There is no address associated with this parent."
                   rendered="#{parentHome.instance.address == null}"/>

        <rich:dataTable var="_address"
                   value="#{parentHome.instance.address}"
                rendered="#{parentHome.instance.address != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="addressTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_address.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line1</f:facet>
                <h:outputText value="#{_address.addressLine1}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line2</f:facet>
                <h:outputText value="#{_address.addressLine2}"/>
            </h:column>
            <h:column>
                <f:facet name="header">City</f:facet>
                <h:outputText value="#{_address.city}"/>
            </h:column>
            <h:column>
                <f:facet name="header">State</f:facet>
                <h:outputText value="#{_address.state}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Country</f:facet>
                <h:outputText value="#{_address.country}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Pin</f:facet>
                <h:outputText value="#{_address.pin}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            
            <s:button id="#{parentHome.instance.address != null ? 'changeParentaddress' : 'selectParentaddress'}" value="#{parentHome.instance.address != null ? 'Change' : 'Select'} address"
                       view="/AddressList.xhtml">
                       
                       
                <f:param name="from" value="ParentEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Student admissions">
        <h:form styleClass="association" id="studentAdmissionsChildren">

            <h:outputText value="There are no studentAdmissions associated with this parent."
                       rendered="#{empty parentHome.studentAdmissions}"/>

            <rich:dataTable value="#{parentHome.studentAdmissions}"
                           var="_studentAdmission"
                      rendered="#{not empty parentHome.studentAdmissions}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentAdmissionsTable">
                <rich:column sortBy="#{_studentAdmission.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentAdmission.id}"/>
                </rich:column>
                <rich:column sortBy="#{_studentAdmission.admissionDate}">
                    <f:facet name="header">Admission date</f:facet>
                    <h:outputText value="#{_studentAdmission.admissionDate}">
                        <s:convertDateTime type="date" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_studentAdmission.admissionFeeAmount}">
                    <f:facet name="header">Admission fee amount</f:facet>
                    <h:outputText value="#{_studentAdmission.admissionFeeAmount}"/>
                </rich:column>
                <rich:column sortBy="#{_studentAdmission.specialFeeAmount}">
                    <f:facet name="header">Special fee amount</f:facet>
                    <h:outputText value="#{_studentAdmission.specialFeeAmount}"/>
                </rich:column>
                <rich:column sortBy="#{_studentAdmission.paymentDate}">
                    <f:facet name="header">Payment date</f:facet>
                    <h:outputText value="#{_studentAdmission.paymentDate}">
                        <s:convertDateTime type="date" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_studentAdmission.eligibleForScholarship}">
                    <f:facet name="header">Eligible for scholarship</f:facet>
                    <h:outputText value="#{_studentAdmission.eligibleForScholarship}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{parentHome.managed}" id="studentAdmissions">
        <div class="actionButtons">
            <s:button id="addstudentAdmission"
                   value="Add studentAdmission"
                    view="/StudentAdmissionEdit.xhtml"
             propagation="none">
                 <f:param name="parentId"
                         value="#{parentHome.instance.id}"/>
                 <f:param name="studentAdmissionFrom" value="Parent"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Student emergency contacts">
        <h:form styleClass="association" id="studentEmergencyContactsChildren">

            <h:outputText value="There are no studentEmergencyContacts associated with this parent."
                       rendered="#{empty parentHome.studentEmergencyContacts}"/>

            <rich:dataTable value="#{parentHome.studentEmergencyContacts}"
                           var="_studentEmergencyContact"
                      rendered="#{not empty parentHome.studentEmergencyContacts}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="studentEmergencyContactsTable">
                <rich:column sortBy="#{_studentEmergencyContact.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_studentEmergencyContact.id}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{parentHome.managed}" id="studentEmergencyContacts">
        <div class="actionButtons">
            <s:button id="addstudentEmergencyContact"
                   value="Add studentEmergencyContact"
                    view="/StudentEmergencyContactEdit.xhtml"
             propagation="none">
                 <f:param name="parentId"
                         value="#{parentHome.instance.id}"/>
                 <f:param name="studentEmergencyContactFrom" value="Parent"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
